home *** CD-ROM | disk | FTP | other *** search
- #
- # fcntl.test
- #
- # Tests for the fcntl command.
- #---------------------------------------------------------------------------
- # Copyright 1992-1993 Karl Lehenbauer and Mark Diekhans.
- #
- # Permission to use, copy, modify, and distribute this software and its
- # documentation for any purpose and without fee is hereby granted, provided
- # that the above copyright notice appear in all copies. Karl Lehenbauer and
- # Mark Diekhans make no representations about the suitability of this
- # software for any purpose. It is provided "as is" without express or
- # implied warranty.
- #------------------------------------------------------------------------------
- # $Id: fcntl.test,v 3.0 1993/11/19 06:57:20 markd Rel $
- #------------------------------------------------------------------------------
- #
-
- if {[info procs test] != "test"} then {source testlib.tcl}
-
- set testFH [open FCNTL.TMP w]
- close $testFH
-
- set testFH [open FCNTL.TMP r+]
-
- pipe testRPH testWPH
-
- Test fcntl-1.1 {fcntl tests} {
- fcntl $testFH RDWR
- } 0 1
-
- Test fcntl-1.2 {fcntl tests} {
- fcntl $testFH READ
- } 0 1
-
- Test fcntl-1.3 {fcntl tests} {
- fcntl $testFH WRITE
- } 0 1
-
- Test fcntl-1.4 {fcntl tests} {
- fcntl $testFH CLOEXEC 1
- fcntl $testFH CLOEXEC
- } 0 1
-
- Test fcntl-1.5 {fcntl tests} {
- fcntl $testFH CLOEXEC 0
- fcntl $testFH CLOEXEC
- } 0 0
-
- Test fcntl-1.6 {fcntl tests} {
- fcntl $testRPH NONBLOCK 1
- fcntl $testRPH NONBLOCK
- } 0 1
-
- Test fcntl-1.7 {fcntl tests} {
- fcntl $testFH append 1
- fcntl $testFH append
- } 0 1
-
- Test fcntl-1.8 {fcntl tests} {
- fcntl $testFH APPEND 0
- fcntl $testFH append
- } 0 0
-
- Test fcntl-1.9 {fcntl tests} {
- fcntl $testRPH NONBLOCK 0
- fcntl $testRPH nonBlock
- } 0 0
-
- Test fcntl-1.10 {fcntl tests} {
- fcntl $testFH NOBUF 1
- fcntl $testFH NObuf
- } 0 1
-
- Test fcntl-1.11 {fcntl tests} {
- fcntl $testFH NOBUF 0
- } 1 {Attribute "NOBUF" may not be cleared once set}
-
- close $testFH
- set testFH [open FCNTL.TMP w] ;# Reopen, can not have both nobuf and linebuf
-
- Test fcntl-1.12 {fcntl tests} {
- fcntl $testFH LINEBUF 1
- fcntl $testFH LINEBUF
- } 0 1
-
- Test fcntl-1.13 {fcntl tests} {
- fcntl $testFH LINEBUF 0
- } 1 {Attribute "LINEBUF" may not be cleared once set}
-
- Test fcntl-1.14 {fcntl tests} {
- fcntl $testFH a b c
- } 1 {wrong # args: fcntl handle attribute ?value?}
-
- Test fcntl-1.15 {fcntl tests} {
- fcntl $testFH BAZ 1
- } 1 {unknown attribute name "BAZ", expected one of APPEND, CLOEXEC, LINEBUF, NONBLOCK, NOBUF, READ, RDONLY, RDWR, WRITE, WRONLY}
-
- Test fcntl-1.16 {fcntl tests} {
- fcntl $testFH APPEND FOO
- } 1 {expected boolean value but got "FOO"}
-
- close $testFH
-
- Test fcntl-1.15 {fcntl tests} {
- fcntl $testFH RDONLY
- } 1 "file \"$testFH\" isn't open"
-
- close $testRPH
- close $testWPH
- unlink FCNTL.TMP
-